package zhongbo.java.air.dictionary.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.PastOrPresent;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.Date;
import java.io.Serializable;

/**
 * 飞机基础信息表(AirAircraft)实体类
 *
 * @author makejava
 * @since 2025-03-31 13:55:16
 */
@Data
@Builder
@AllArgsConstructor
@TableName("air_aircraft")
@ApiModel("飞机信息")
public class AirAircraft implements Serializable {
    /**
     * UUID 主键
     */
    @ApiModelProperty(value = "UUID 主键",example = "1")
    @TableId(type = IdType.ASSIGN_UUID)
    @NotNull(message = "UUID不能为空")
    @Size(min = 1, max = 36, message = "UUID长度应在1到36个字符之间")
    private String id;
    /**
     * ICAO 24位地址码（唯一业务编号）
     */
    @ApiModelProperty(value = "ICAO 24位地址码",example = "122")
    @NotNull(message = "ICAO 24位地址码不能为空")
    @Size(min = 1, max = 6, message = "ICAO 24位地址码长度应在1到6个字符之间")
    @Pattern(regexp = "^[A-Z0-9]{1,6}$", message = "ICAO 24位地址码必须是1到6位的字母或数字")
    private String icaoCode;
    /**
     * 飞机注册号（如 B-1234）
     */
    @ApiModelProperty(value = "飞机注册号",example = "B-1234")
    @NotNull(message = "飞机注册号不能为空")
    @Size(min = 1, max = 20, message = "飞机注册号长度应在1到20个字符之间")
    @Pattern(regexp = "^[A-Z0-9-]{1,20}$", message = "飞机注册号必须是1到20位的字母、数字或连字符")
    private String registration;
    /**
     * 所属航空公司
     */
    @ApiModelProperty(value = "所属航空公司",example = "AT11")
    @NotNull(message = "所属航空公司不能为空")
    @Size(min = 1, max = 50, message = "所属航空公司长度应在1到50个字符之间")
    @Pattern(regexp = "^[A-Z0-9-]{1,50}$", message = "所属航空公司必须是1到50位的字母、数字或连字符")
    private String airline;
    /**
     * 机型（枚举值示例：B737-800, A320-200）
     */
    @ApiModelProperty(value = "机型",example ="B737-800" )
    @NotNull(message = "机型不能为空")
    @Size(min = 1, max = 30, message = "机型长度应在1到30个字符之间")
    private String aircraftType;
    /**
     * 状态（枚举值：ACTIVE-运营中, MAINTENANCE-维护中, RETIRED-已退役）
     */
    @ApiModelProperty(value = "状态",example ="ACTIVE" )
    @NotNull(message = "状态不能为空")
    @Size(min = 1, max = 20, message = "状态长度应在1到20个字符之间")
    @Pattern(regexp = "^(ACTIVE|MAINTENANCE|RETIRED)$", message = "状态必须是 ACTIVE, MAINTENANCE 或 RETIRED")
    private String status;
    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间",example = "2025-03-31 15:19:25")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    @NotNull(message = "创建时间不能为空")
    @PastOrPresent(message = "创建时间必须是过去或现在")
    private Date createTime;
    /**
     * 更新时间
     */
    @ApiModelProperty(value = "更新时间",example = "2025-04-11 15:19:25")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    @NotNull(message = "更新时间不能为空")
    @PastOrPresent(message = "更新时间必须是过去或现在")
    private Date updateTime;

    // 修改默认构造函数，自动设置 createTime 和 updateTime
    public AirAircraft() {
        this.createTime = new Date();
        this.updateTime = new Date();
    }

    // 新增构造函数，自动设置 createTime 和 updateTime
    public AirAircraft(String id, String icaoCode, String registration, String airline, String aircraftType, String status) {
        this.id = id;
        this.icaoCode = icaoCode;
        this.registration = registration;
        this.airline = airline;
        this.aircraftType = aircraftType;
        this.status = status;
        this.createTime = new Date();
        this.updateTime = new Date();
    }
}